/// *
// * To change this template, choose Tools | Templates
// * and open the template in the editor.
// */
//package main_com.Controlers.date.old;
//
//import jakarta.servlet.ServletException;
//import jakarta.servlet.http.HttpServletRequest;
//import jakarta.servlet.http.HttpServletResponse;
//import jakarta.servlet.http.HttpSession;
//import main_com.mapper.DateMapper;
//import main_com.pojo.LoginBean;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.RequestMapping;
//
//import java.io.IOException;
//import java.util.ArrayList;
//
///**
// * @author Administrator
// */
//
//@Controller
//@RequestMapping("/DeleteDateController")
//public class DeleteDateController {
//    //    public void wrong1(){
////        String msg="请把日期填写完整，删除失败！";
////        int type=JOptionPane.YES_NO_CANCEL_OPTION;
////        String title="信息提示";
////        JOptionPane.showMessageDialog(null, msg, title, type);
////    }
////    public void wrong2(){
////        String msg="请确认日期填写正确，删除失败！";
////        int type=JOptionPane.YES_NO_CANCEL_OPTION;
////        String title="信息提示";
////        JOptionPane.showMessageDialog(null, msg, title, type);
////    }
////    public void wrong3(){
////        String msg="该日程不存在，删除失败！";
////        int type=JOptionPane.YES_NO_CANCEL_OPTION;
////        String title="信息提示";
////        JOptionPane.showMessageDialog(null, msg, title, type);
////    }
////    public void right(){
////        String msg="填写信息合格，删除成功！";
////        int type=JOptionPane.YES_NO_CANCEL_OPTION;
////        String title="信息提示";
////        JOptionPane.showMessageDialog(null, msg, title, type);
////    }
//    @Autowired
//    DateMapper dateMapper;
//
//    @RequestMapping("/deleteDate")
//    protected void deleteDate(HttpServletRequest request, HttpServletResponse response)
//            throws ServletException, IOException {
//        String year = request.getParameter("year");
//        String month = request.getParameter("month");
//        String day = request.getParameter("day");
//        String date = "20" + year + "-" + month + "-" + day;
//        if (year.isEmpty() || month.isEmpty() || day.isEmpty()) {
////            wrong1();
//            response.sendRedirect("http://localhost/dateManager/deleteDate.jsp");
//        } else if (year.length() != 2 || Integer.parseInt(year) < 11 || Integer.parseInt(month) > 12 || Integer.parseInt(day) > 31) {
////            wrong2();
//            response.sendRedirect("http://localhost/dateManager/deleteDate.jsp");
//        } else {
//            try {
//                String userName = "";
//                HttpSession session = request.getSession();
//                ArrayList login = (ArrayList) session.getAttribute("login");
//                if (login == null || login.size() == 0) {
//                    response.sendRedirect("http://localhost/login.jsp");
//                } else {
//                    for (int i = login.size() - 1; i >= 0; i--) {
//                        LoginBean nn = (LoginBean) login.get(i);
//                        userName = nn.getUserName();
//                    }
//                }
//                int k = dateMapper.findDateByDateAndUserName(date, userName);
//                if (k < 1) {
////                    wrong3();
//                    session.setAttribute("datelist", null);
//                    response.sendRedirect("http://localhost/dateManager/deleteDate.jsp");
//                } else {
//                    dateMapper.deleteDate(userName, date);
//                    ArrayList datelist = null;
//                    datelist = dateMapper.getDateByUserName(userName);
//                    session.setAttribute("datelist", datelist);
////                    right();
//                    response.sendRedirect("http://localhost/dateManager/lookDate.jsp");
//
//                }
//            } catch (Exception e) {
//                e.printStackTrace();
//            }
//        }
//    }
//
//
//}